$(window).load(function(){
	/* 地址操作及管理 */
	// 获取默认地址，有地址则显示默认地址，没有地址则新增地址按钮
	var getAddress = wxAddress + "/weixin/getAddress";
	var hasDefault = 0;
	ajaxEncapsulation(getAddress, getAddressSuc, "", "GET", "true");

	function getAddressSuc(data){
		console.log(data);
		if(data.code == "0000"){
			var addressList = data.data;
			if(addressList.length == 0){
				$(".order-addaddress").removeAttr("style");
			}else if(addressList.length > 0){
				for(var i=0;i<addressList.length;i++){
					if(addressList[i].isdefault == "1"){
						var addressInfoDiv = $('<div class="isflex"><div class="order-titleone"><p>收&ensp;件&ensp;人：</p><p class="order-nameaddress" email="'+addressList[i].email+'" phone="'+addressList[i].addresseemobile+'">'+addressList[i].addresseename+'</p></div><div class="order-titletwo isflexbox"><p>收件地址：</p><p class="order-addressaddress isflex" addressid="'+addressList[i].id+'" provincecode="'+addressList[i].addresseeprovince+'" citycode="'+addressList[i].addresseecity+'" districtcode="'+addressList[i].addresseecounty+'">'+addressList[i].addresseeprovincename+addressList[i].addresseecityname+addressList[i].addresseecountyname+addressList[i].addresseedetails+'</p></div></div><img class="order-arrow" src="images/right_arrow.png" />');
						addressInfoDiv.appendTo(".order-infoaddress");
						hasDefault = 1;
					}
				}
				if(hasDefault == 0){
					var noDefaultDiv = $('<div class="isflex"><div class="order-titleone"><p>收&ensp;件&ensp;人：</p><p class="order-nameaddress"></p></div><div class="order-titletwo isflexbox"><p>收件地址：</p><p class="order-addressaddress isflex"></p></div></div><img class="order-arrow" src="images/right_arrow.png" />');
					noDefaultDiv.appendTo(".order-infoaddress");
				}
				$(".order-infoaddress").removeAttr("style");
				addressLayout(addressList);
			}
		}else{
			warnText($(".red-bg"),"获取地址接口失败！",1000);
		}
	}

	// 初始获取到地址，点击进入地址列表
	$(".order-address").delegate(".order-infoaddress", "click", function(){
		$(".order-main").hide();
		$(".address-main").show();
		$("title").text("配送地址");
	})

	// 地址列表，新增地址
	$(".address-next").delegate("p", "click", function(){
		dealAddUpdate("insert");
		$(".address-main").hide();
		$(".operate-address").show();
	})

	// 地址列表，编辑修改地址
	var findAddress = wxAddress + "/weixin/findAddress";
	$(".address-main").delegate(".address-update", "click", function(){
		var findAddressId = {
			id: $(".address-default").attr("addressid")
		}
		ajaxEncapsulation(findAddress, findAddressSuc, "", "POST", "true", findAddressId);
	})

	function findAddressSuc(data){
		console.log(data);
		if(data.code == "0000" && data.data != null && data.data != "" && data.data != undefined){
			dealAddUpdate("update", data.data);
			$(".address-main").hide();
			$(".operate-address").show();
		}else{
			warnText($(".red-bg"),"获取地址详情信息失败！",1000);
		}
	}

	// 地址列表，删除地址
	var delAddress = wxAddress + "/weixin/delAddress";
	var deleteSucNum = 0;
	$(".address-main").delegate(".address-delete", "click", function(){
		deleteSucNum = 0;
		var deleteTargetId = $(this).parents(".address-operate").find(".address-default").attr("addressid");
		var deldeteId = {
			id: deleteTargetId
		}
		ajaxEncapsulation(delAddress, delAddressSuc, "", "POST", "false", deldeteId);
		if(deleteSucNum == 1){
			$(this).parents("li").remove();
			warnText($(".red-bg"),"删除地址成功！",1000);
		}else if(deleteSucNum == 0){
			warnText($(".red-bg"),"删除地址失败！",1000);
		}
	})

	function delAddressSuc(data){
		console.log(data);
		if(data.code == "0000"){
			deleteSucNum = 1;
		}
	}

	// 初始未获取到地址，点击添加地址
	$(".order-address").delegate(".order-addaddress", "click", function(){
		$(".order-main").hide();
		dealAddUpdate("insert", "");
		$(".operate-address").show();
		$("title").text("配送地址");
	})

	// 新增地址、修改地址
	var updateAddressNum = 0;
	var insertAddressNum = 0;
	var addAddress = wxAddress + "/weixin/addAddress";
	$(".operate-save").on("click", function(){
		if($(".operate-name").val().trim() == ""){
			warnText($(".red-bg"),"收货人姓名不能为空！",1000);
			return false;
		}
		if($(".operate-phone").val() == ""){
			warnText($(".red-bg"),"收货人电话不能为空！",1000);
			return false;
		}else if(regs.phoneReg.test($(".operate-phone").val()) == false){
			warnText($(".red-bg"),"收货人手机号格式错误！",1000);
			return false;
		}
		if($(".operate-email").val() == ""){
			
		}else if(regs.emailReg.test($(".operate-email").val()) == false){
			warnText($(".red-bg"),"邮箱格式错误！",1000);
			return false;
		}
		if($("#choiceAddressPicker").attr("provinceCode") == "" || $("#choiceAddressPicker").attr("provinceCode") == undefined){
			warnText($(".red-bg"),"所选地区省不能为空！",1000);
			return false;
		}
		if($("#choiceAddressPicker").attr("cityCode") == "" || $("#choiceAddressPicker").attr("cityCode") == undefined){
			warnText($(".red-bg"),"所选地区市不能为空！",1000);
			return false;
		}
		if($("#choiceAddressPicker").attr("districtCode") == "" || $("#choiceAddressPicker").attr("districtCode") == undefined){
			warnText($(".red-bg"),"所选地区行政区不能为空！",1000);
			return false;
		}
		if($(".operate-detailAdd").val().trim().length < 5){
			warnText($(".red-bg"),"详细地址至少5个字！",1000);
			return false;
		}
		if(insertAddressNum == 1){// 新增地址
			var addressInfo = {
				addresseename: $(".operate-name").val().trim(),
				addresseemobile: $(".operate-phone").val(),
				email: $(".operate-email").val(),
				addresseedetails: $(".operate-detailAdd").val().trim(),
				addresseecounty: $("#choiceAddressPicker").attr("districtCode"),
				addresseecity: $("#choiceAddressPicker").attr("cityCode"),
				addresseeprovince: $("#choiceAddressPicker").attr("provinceCode"),
				addresseecountyname: districtName,
				addresseecityname: cityName,
				addresseeprovincename: provinceName,
				isdefault: isdefault
			};
			ajaxEncapsulation(addAddress, addAddressSuc, "", "POST", "true", addressInfo);
		}
		if(updateAddressNum == 1){
			// 修改地址
			var addressInfo = {
				addresseename: $(".operate-name").val().trim(),
				addresseemobile: $(".operate-phone").val(),
				email: $(".operate-email").val(),
				addresseedetails: $(".operate-detailAdd").val().trim(),
				addresseecounty: $("#choiceAddressPicker").attr("districtCode"),
				addresseecity: $("#choiceAddressPicker").attr("cityCode"),
				addresseeprovince: $("#choiceAddressPicker").attr("provinceCode"),
				addresseecountyname: districtName,
				addresseecityname: cityName,
				addresseeprovincename: provinceName,
				id: $(".operate-name").attr("addressId"),
				isdefault: isdefault
			};
			ajaxEncapsulation(addAddress, addAddressSuc, "", "POST", "true", addressInfo);
		}
	})

	function addAddressSuc(data){
		console.log(data);
		if(data.code == "0000"){
			if(insertAddressNum == 1){
				warnText($(".red-bg"),"新增地址成功！",1000);
				insertAddressNum = 0;
			}else if(updateAddressNum == 1){
				warnText($(".red-bg"),"修改地址成功！",1000);
				updateAddressNum = 0;
			}
			$(".operate-address").hide();
			$(".address-main").show();
			ajaxEncapsulation(getAddress, getAddressListSuc, "", "GET", "true");
		}else{
			if(insertAddressNum == 1){
				warnText($(".red-bg"),"新增地址失败！",1000);
			}else if(updateAddressNum == 1){
				warnText($(".red-bg"),"修改地址失败！",1000);
			}
		}
	}

	function getAddressListSuc(data){
		addressLayout(data.data);
	}

	// 新增地址时，输入内容置空；修改内容时，修改内容放入文本框
	function dealAddUpdate(ways, data){
		if(ways == "insert"){
			$(".operate-name").val("");
			$(".operate-phone").val("");
			$(".operate-email").val("");
			$("#choiceAddressPicker").val("");
			$("#choiceAddressPicker").attr("provinceCode", "");
			$("#choiceAddressPicker").attr("cityCode", "");
			$("#choiceAddressPicker").attr("districtCode", "");
			$(".operate-detailAdd").val("");
			$(".isdefault").find("p").css({left: "46.2025%"});
			$(".isdefault").css({backgroundColor: "#EA4040"});
			isdefault = 1;
			insertAddressNum = 1;
		}else if(ways == "update"){
			$(".operate-name").val(data.addresseename);
			$(".operate-name").attr("addressId", data.id);
			$(".operate-phone").val(data.addresseemobile);
			$(".operate-email").val(data.email);
			$("#choiceAddressPicker").val(data.addresseeprovincename+"-"+data.addresseecityname+"-"+data.addresseecountyname);
			$("#choiceAddressPicker").attr("provinceCode", data.addresseeprovince);
			$("#choiceAddressPicker").attr("cityCode", data.addresseecity);
			$("#choiceAddressPicker").attr("districtCode", data.addresseecounty);
			$(".operate-detailAdd").val(data.addresseedetails);
			$(".isdefault").find("p").css({left: "46.2025%"});
			$(".isdefault").css({backgroundColor: "#EA4040"});
			isdefault = 1;
			updateAddressNum = 1;
		}
	}

	// 地址列表排版
	function addressLayout(data){
		$(".address-main ul").html("");
		for(var i=0;i<data.length;i++){
			if(data[i].isdefault == "1"){
				var addressLiImg = "images/user_on.png";
				var addressLiCheck = "checked";
			}else{
				var addressLiImg = "images/user_un.png";
				var addressLiCheck = "";
			}
			var addressLi = $('<li><div class="address-info"><div class="isflexbox"><p class="address-infoname" email="'+data[i].email+'">'+data[i].addresseename+'</p><p class="address-infophone">'+data[i].addresseemobile+'</p></div><p class="address-detailed" provincecode="'+data[i].addresseeprovince+'" citycode="'+data[i].addresseecity+'" districtcode="'+data[i].addresseecounty+'">'+data[i].addresseeprovincename+data[i].addresseecityname+data[i].addresseecountyname+data[i].addresseedetails+'</p></div><div class="address-operate isflexbox"><div class="address-default" addressid="'+data[i].id+'"><img src="'+addressLiImg+'" /><p>默认地址</p><input type="radio" value="" name="choice" '+addressLiCheck+' /></div><div class="isflexbox"><div class="address-update"><img src="images/order_add.png" /><p>编辑</p></div><div class="address-delete"><img src="images/order_del.png" /><p>删除</p></div></div></div></li>');
			if(data[i].isdefault == "1"){
				addressLi.prependTo(".address-main ul");
			}else{
				addressLi.appendTo(".address-main ul");
			}
		}
	}

	// 地址列表：点击转换展示
	$(".address-main").delegate(".address-info", "click", function(){
		var choiceTargetAddName = $(this).find(".address-infoname").text();
		var choiceTargetEmail = $(this).find(".address-infoname").attr("email");
		var choiceTargetPhone = $(this).find(".address-infophone").text();
		var choiceTargetAddId = $(this).siblings(".address-operate").find(".address-default").attr("addressid");
		var choiceTargetAddText = $(this).find(".address-detailed").text();
		var choiceProvinceCode = $(this).find(".address-detailed").attr("provincecode");
		var choiceCityCode = $(this).find(".address-detailed").attr("citycode");
		var choiceDistrictCode = $(this).find(".address-detailed").attr("districtcode");
		$(".order-nameaddress").text(choiceTargetAddName);
		$(".order-nameaddress").attr("email", choiceTargetEmail);
		$(".order-nameaddress").attr("phone", choiceTargetPhone);
		$(".order-addressaddress").attr("addressid", choiceTargetAddId);
		$(".order-addressaddress").attr("provincecode", choiceProvinceCode);
		$(".order-addressaddress").attr("citycode", choiceCityCode);
		$(".order-addressaddress").attr("districtcode", choiceDistrictCode);
		$(".order-addressaddress").text(choiceTargetAddText);
		$(".address-main").hide();
		$(".order-main").show();
		$("title").text("报价详情");
	});

	// 地址列表：地址设为默认
	var setDefault = wxAddress + "/weixin/setDefault";
	var setDefaultNum = 0;
	$(".address-main").delegate(".address-default", "click", function(){
		if($(this).find("input").prop("checked")){
			$(this).find("img").attr("src", "images/user_on.png");
			$(this).parents("li").siblings("li").find(".address-default").find("img").attr("src", "images/user_un.png");
		}else{
			var setDefaultTargetId = $(this).attr("addressid");
			var setDefaultId = {
				id: setDefaultTargetId
			}
			ajaxEncapsulation(setDefault, setDefaultSuc, "", "POST", "false", setDefaultId);
			if(setDefaultNum == 1){
				$(this).find("input").prop("checked",true);
				$(this).find("img").attr("src", "images/user_on.png");
				$(this).parents("li").siblings("li").find(".address-default").find("img").attr("src", "images/user_un.png");
				warnText($(".red-bg"),"地址设为默认成功！",1000);
			}else if(setDefaultNum == 0){
				warnText($(".red-bg"),"地址设为默认失败！",1000);
			}
		}
	})

	function setDefaultSuc(data){
		console.log(data);
		if(data.code == "0000"){
			setDefaultNum = 1;
		}
	}

	// 新增、修改地址信息时设为默认
	var isdefault = 1;
	$(".isdefault").on("click", function(){
		if(isdefault == 1){
			$(this).find("p").stop().animate({left: "0"},"normal",function(){
				$(this).parent().css({backgroundColor: "#F0F0F0"});
				isdefault = 0;
			});
		}else  if(isdefault == 0){
			$(this).find("p").stop().animate({left: "46.2025%"},"normal",function(){
				$(this).parent().css({backgroundColor: "#EA4040"});
				isdefault = 1;
			});
		}
	})



	/* 获取保险信息，渲染DOM结构，展示订单信息 */
	var orderCom = JSON.parse(localStorage.getItem("eBizOrderCompany"));
	if(orderCom){
		$(".detail-pricel").html('<img src="'+orderCom.image+'" /><p class="text-two">'+orderCom.name+'</p>');
	}else{
		warnText($(".red-bg"),"未获取到保险公司信息！",1000);
	}
	var orderMsg = JSON.parse(localStorage.getItem("eBizOrderMsg"));
	var reinsurancePrice;
	var reinsuranceContent = "";
	if(orderMsg){
		for(var key in orderMsg){
			var orderInfo = orderMsg[key].data[0];
			reinsurancePrice = orderMsg[key].totalPremium;
			if(orderInfo.biPremium == "" || orderInfo.biPremium == null || orderInfo.biPremium == undefined){
				orderInfo.biPremium = 0;
			}
			if(orderInfo.carshipTax == "" || orderInfo.carshipTax == null || orderInfo.carshipTax == undefined){
				orderInfo.carshipTax = 0;
			}
			if(orderInfo.ciPremium == "" || orderInfo.ciPremium == null || orderInfo.ciPremium == undefined){
				orderInfo.ciPremium = 0;
			}
			if(orderInfo.rebates == "" || orderInfo.rebates == null || orderInfo.rebates == undefined){
				orderInfo.rebates = 0;
			}
			reinsuranceContent = reinsuranceContent + "车船税/保费(￥"+orderInfo.carshipTax+"元),";
			var totalPrice = (parseFloat(orderInfo.biPremium)+parseFloat(orderInfo.carshipTax)+parseFloat(orderInfo.ciPremium)).toFixed(2);
			var actPrice = (parseFloat(totalPrice)-parseFloat(orderInfo.rebates)).toFixed(2);
			$(".detail-pricer").html('<p><span class="text-two">总价：</span><span class="text-four">￥'+totalPrice+'</span></p><p><span class="text-two">优惠：</span><span class="text-five">￥'+orderInfo.rebates+'</span></p><p><span class="text-two">实付：</span><span class="text-six">￥'+actPrice+'</span></p>');
			
			var ciAndCarShip = $('<div class="line"></div><p class="p-one"><span class="text-one">交强险（保险起期：'+orderInfo.ciBeginDate+'）</span><span class="text-two">¥'+orderInfo.ciPremium+'</span></p><div class="line"></div><p class="p-one"><span class="text-one">车船税</span><span class="text-two">¥'+orderInfo.carshipTax+'</span></p><div class="line"></div>');
			ciAndCarShip.appendTo(".detail-content");
			var bizDetail = orderInfo.CoverageList;
			console.log(bizDetail);
			for(var i=0;i<bizDetail.length;i++){
				if(bizDetail[i].amount == ""){
					var bizDetailAmount = "";
				}else{
					var bizDetailAmount = bizDetail[i].amount + ".00元";
				}
				reinsuranceContent = reinsuranceContent+bizDetail[i].coverageName+bizDetailAmount+"/"+"保费(￥"+bizDetail[i].insuredPremium+"元),";
				if(bizDetail[i].coverageCode != "FORCEPREMIUM"){
					if(bizDetail[i].insuredAmount == "Y"){
						var bizInsuranceList = $('<p class="p-three"><span class="text-one">'+bizDetail[i].coverageName+'</span><span class="text-two">¥'+bizDetail[i].insuredPremium+'</span></p>');
						bizInsuranceList.appendTo(".detail-content");
					}else{
						var bizDetailPrice = bizDetail[i].insuredAmount / 10000;
						var bizInsuranceList = $('<div class="div-one"><span class="text-one">'+bizDetail[i].coverageName+'</span><p class="p-four"><span class="text-two">'+bizDetailPrice+'万</span><span class="text-two">¥'+bizDetail[i].insuredPremium+'</span></p></div>');
						bizInsuranceList.appendTo(".detail-content");
					}
				}
			}
			reinsuranceContent = reinsuranceContent+ "总保费合计"+reinsurancePrice+"元";
			console.log(reinsuranceContent);
			var bi = $('<p class="p-one"><span class="text-one">商业险合计（保险起期：'+orderInfo.biBeginDate+'）</span><span class="text-two">¥'+orderInfo.biPremium+'</span></p>');
			bi.appendTo(".detail-content");
			var personInfo = orderMsg[key].tWeixinTruckInfo;
			$(".ownerName").val(personInfo.ownerName);
			$(".ownerID").val(personInfo.ownerIdNo);
			$(".ownerMobile").val(personInfo.ownerMobile);
			$(".applicantName").val(personInfo.applicantName);
			$(".applicantID").val(personInfo.applicantIdCard);
			$(".applicantMobile").val(personInfo.applicantPhone);
			$(".insuredName").val(personInfo.recognizeeName);
			$(".insuredID").val(personInfo.recognizeeIdCard);
			$(".insuredMobile").val(personInfo.recognizeePhone);
			if(personInfo.istrans == 0){
				var istransCode = "否";
			}else if(personInfo.istrans == 1){
				var istransCode = "是";
			}
			var carmsgList = $('<li class="isflexbox"><p>车牌号：</p><p>'+personInfo.licenseno+'</p></li><li class="isflexbox"><p>车架号：</p><p>'+personInfo.frameno+'</p></li><li class="isflexbox"><p>品牌型号：</p><p>'+personInfo.brandname+'</p></li><li class="isflexbox"><p>发动机号：</p><p>'+personInfo.engineno+'</p></li><li class="isflexbox"><p>注册日期：</p><p>'+personInfo.registerdate+'</p></li><li class="isflexbox"><p>是否过户：</p><p>'+istransCode+'</p></li>');
			carmsgList.appendTo(".car-msg ul");
			if(personInfo.istrans == 1){
				var transDataLi = $('</li><li class="isflexbox"><p>是否过户：</p><p>'+personInfo.transdate+'</p></li>');
				transDataLi.appendTo(".car-msg ul");
			}
		}
	}else{
		warnText($(".red-bg"),"未获取到保险信息！",1000);
	}



	/* 投保人信息，被保人信息，投保协议按钮，核保按钮 */
	var isapplicant = 1;
	var isrecognizee = 1;
	var isagreement = 1;
	//投保人信息展示按钮
	$(".isapplicant").on("click", function(){
		if(isapplicant == 1){
			$(this).find("p").stop().animate({left: "0"},"normal",function(){
				$(this).parent().css({backgroundColor: "#F0F0F0"});
				$(this).parent().siblings(".owners-same").text("隐藏信息");
				$(".applicant-info").hide();
				isapplicant = 0;
			});
		}else  if(isapplicant == 0){
			$(this).find("p").stop().animate({left: "46.2025%"},"normal",function(){
				$(this).parent().css({backgroundColor: "#EA4040"});
				$(this).parent().siblings(".owners-same").text("展开信息");
				$(".applicant-info").show();
				isapplicant = 1;
			});
		}
	})

	//被保人信息展示按钮
	$(".isrecognizee").on("click", function(){
		if(isrecognizee == 1){
			$(this).find("p").stop().animate({left: "0"},"normal",function(){
				$(this).parent().css({backgroundColor: "#F0F0F0"});
				$(this).parent().siblings(".owners-same").text("隐藏信息");
				$(".recognizee-info").hide();
				isrecognizee = 0;
			});
		}else  if(isrecognizee == 0){
			$(this).find("p").stop().animate({left: "46.2025%"},"normal",function(){
				$(this).parent().css({backgroundColor: "#EA4040"});
				$(this).parent().siblings(".owners-same").text("展开信息");
				$(".recognizee-info").show();
				isrecognizee = 1;
			});
		}
	})

	//投保协议按钮
	$(".isagreement").on("click", function(){
		if(isagreement == 1){
			$(this).find("p").stop().animate({left: "0"},"normal",function(){
				$(this).parent().css({backgroundColor: "#F0F0F0"});
				isagreement = 0;
			});
		}else  if(isagreement == 0){
			$(this).find("p").stop().animate({left: "46.2025%"},"normal",function(){
				$(this).parent().css({backgroundColor: "#EA4040"});
				isagreement = 1;
			});
		}
	})

	// 阅读投保协议
	$(".order-protocol span").on("click", function(){
		$("html").css({"height": "100%", "overflow": "hidden"});
		$(".insurance-agreement").show();
		$(".masklayer").show();
	})

	// 关闭投保协议
	$(".insurance-agreement span").on("click", function(){
		$(".insurance-agreement").hide();
		$("html").css({"height": "auto", "overflow": "scroll"});
		$(".masklayer").hide();
	})

	// 核保
	var reinsurance = wxAddress + "/insurance/reinsurance";
	$(".order-next").on("click", function(){
		if($(".order-nameaddress").text() == "" || $(".order-addressaddress").text() == ""){
			warnText($(".red-bg"),"请先选择保单配送地址！",1000);
			return false;
		}
		if(isagreement==0){
			warnText($(".red-bg"),"请先同意投保协议！",1000);
			return false;
		}
		var unPostValue = JSON.parse(localStorage.getItem("eBizUnderWriteValue"));
		var reinsuranceValue = {
			insurerCode: unPostValue.insurerCode,
			bizID: unPostValue.bizID,
			addresseeName: $(".order-nameaddress").text(),
			addresseeMobile: $(".order-nameaddress").attr("phone"),
			addresseeDetails: $(".order-addressaddress").text(),
			addresseeCounty: $(".order-addressaddress").attr("districtcode"),
			addresseeCity: $(".order-addressaddress").attr("citycode"),
			addresseeProvince: $(".order-addressaddress").attr("provincecode"),
			policyEmail: $(".order-nameaddress").attr("email"),
			money: reinsurancePrice,
			content: reinsuranceContent
		}
		$(".masklayer").show();
		$(".maskImg").show();
		ajaxEncapsulation(reinsurance, reinsuranceSuc, reinsuranceErr, "POST", "true", reinsuranceValue);
	})

	function reinsuranceSuc(data, postValue){
		console.log(data);
		$(".masklayer").hide();
		$(".maskImg").hide();
		if(data.code == "0000"){
			window.localStorage.setItem("eBizSucReinsurance", JSON.stringify(data.data));
			window.location.href = "bizpayment.html";
		}else{
			window.localStorage.setItem("eBizFalseReinsurance", JSON.stringify(data.msg));
			window.location.href = "bizunderwriting.html";
		}
	}

	function reinsuranceErr(data){
		$(".masklayer").hide();
		$(".maskImg").hide();
		warnText($(".red-bg"),"网络异常！",1000);
	}



	/* 获取省市级三级联动，用于填写保单地址，地址管理 */
	var getJsonData = wxAddress + "/weixin/getJsonData";
	var multiPickerJson;
	ajaxEncapsulation(getJsonData, getJsonDataSuc, "", "GET", "false");

	function getJsonDataSuc(data){
		console.log(data);
		if(data.code == "0000"){
			multiPickerJson = data.data;
		}else{
			warnText($(".red-bg"),"获取省市区联动失败！",1000);
		}
	}
	
	var firstPickerAdd = 0;
	var provinceName,cityName,districtName;
	new MultiPicker({
		input: "choiceAddressPicker",
		container: "AddressPickerContainer",
		jsonData: multiPickerJson,
		success: function(arr){
			if(firstPickerAdd == 1){
				provinceName = "";
				cityName = "";
				districtName = "";
				$("#choiceAddressPicker").attr("provinceCode", "");
				$("#choiceAddressPicker").attr("cityCode", "");
				$("#choiceAddressPicker").attr("districtCode", "");
			}
			firstPickerAdd = 1;
			var addressPCD = "";
			for(var i=0;i<arr.length;i++){
				if(i==0){
					addressPCD = arr[0].value;
					provinceName = arr[0].value;
					$("#choiceAddressPicker").attr("provinceCode", arr[0].id);
					$("#choiceAddressPicker").val(addressPCD);
				}else if(i==1){
					addressPCD = arr[0].value+"-"+arr[1].value;
					cityName = arr[1].value;
					$("#choiceAddressPicker").attr("cityCode", arr[1].id);
					$("#choiceAddressPicker").val(addressPCD);
				}else if(i==2){
					addressPCD = arr[0].value+"-"+arr[1].value+"-"+arr[2].value;
					districtName = arr[2].value;
					$("#choiceAddressPicker").attr("districtCode", arr[2].id);
					$("#choiceAddressPicker").val(addressPCD);
				}
			}
		}
	});
})